/**
  @file: SettingsKeys.java

  PURPOSE:
  Defines a single location for all keys used when accessing Settings.

  @author Ron Williams

  REVISION HISTORY ABSTRACT

  PROGRAMMER:  Ron Williams            ORG: MSE

  Copyright 2011 Mission Solutions LLC. All rights reserved.

  END ABSTRACT
 */
package com.mse.utilities;


/**
  DESCRIPTION:
  This class defines a single source for all keys used to access Settings.
 */
public class SettingsKeys {
    /**
     General Keys
     */
    public static final String Deploy_RootDir = "Deploy.rootDir";
    
    /**
     RESOURCE based Keys
     */
    public static final String CIWI_VersionMajor = "CIWi.VersionMajor";
    public static final String CIWI_VersionMinor = "CIWi.VersionMinor";
    public static final String CIWI_AuthSaltLength = "CIWi.Auth.SaltLength";
    public static final String CIWI_AuthHashAlg    = "CIWi.Auth.Hash";
    public static final String CIWi_DB_DAOFactoryClass = "ciwi.daoFactoryClass";
    public static final String CIWi_DB_DAOClass    = "ciwi.daoClass";
    public static final String CIWI_Classname      = "ciwi.className";
    public static final String CIWI_UserManagerClass = "ciwi.userManagerClass";
    
    public static final String CRUX_VersionMajor = "CRUX.VersionMajor";
    public static final String CRUX_VersionMinor = "CRUX.VersionMinor";
    public static final String CRUX_AuthSaltLength = "CRUX.Auth.SaltLength";
    public static final String CRUX_AuthHashAlg    = "CRUX.Auth.Hash";
    public static final String CRUX_Classname      = "crux.className";
    public static final String CRUX_SVC_DAOClass = "CRUX.cruxApp.database.DAOClassName";
    public static final String CRUX_Util_DAOClass = "CRUX.configTool.database.DAOClassName";
    public static final String CRUX_UserManagerClass = "CRUX.userManagerClass";
    
    public static final String SVC_VersionMajor = "SVC.VersionMajor";
    public static final String SVC_VersionMinor = "SVC.VersionMinor";
    
    /**
     Log related keys
     */
    public static final String Log_Level = "log.level";
    public static final String Log_ConsoleEnabled = "log.consoleEnabled";
    public static final String Log_FileEnabled    = "log.fileEnabled";
    public static final String Log_FileLimit      = "log.fileLimit";
    public static final String Log_FileCount      = "log.fileCount";
    public static final String Log_FileAppend     = "log.fileAppend";
    public static final String Log_FilePattern    = "log.filePattern";
    
    /**
     Service related keys
     */
    public static final String SVC_EnginePollPeriod = "engine.pollPeriod";
    public static final String SVC_ControlHostname  = "control.hostname";
    public static final String SVC_ControlPort      = "control.port";
    public static final String SVC_LoadProcess      = "load.process";
    public static final String SVC_LoadCiwiInstall  = "load.ciwi_install";
    public static final String SVC_LoadCiwiUninstall = "load.ciwi_uninstall";
    public static final String SVC_LoadCiwiOpenPkg   = "load.ciwi_open_package";
    public static final String SVC_LoadCiwiGenReport = "load.ciwi_generate_report";
    public static final String SVC_LoadCruxTest      = "load.crux_test";
    
    /**
     Crux related keys
     */
    public static final String CRUX_DeleteWorkspaces  = "crux.deleteWorkspaces";
    public static final String CRUX_DB_URL = "crux.database.url";
    public static final String CRUX_DB_DriverClass = "crux.database.driverclassname";
    
    public static final String CRUX_DB_AuthPath = "crux.dbAuthPath";
    public static final String CRUX_DB_User     = "crux.database.user";
    public static final String CRUX_DB_Pass     = "crux.database.password";
    
    public static final String CRUX_Exchange_RootDir = "crux.exchangeRootDir";
    
    /**
     CIWi related keys
     */
    public static final String CIWi_DeleteWorkspaces  = "ciwi.deleteWorkspaces";
    public static final String CIWi_DB_URL      = "ciwi.dbUrl";
    public static final String CIWi_DB_Driver   = "ciwi.dbDriver";
    
    public static final String CIWi_DB_AuthPath = "ciwi.dbAuthPath";
    public static final String CIWi_DB_User     = "ciwi.dbUser";
    public static final String CIWi_DB_Pass     = "ciwi.dbPassword";
    
    public static final String CIWi_DAOMethodLoggingEnabled = "ciwi.daoMethodLoggingEnabled";
    public static final String CIWi_DAOAssertionsEnabled = "ciwi.daoAssertionsEnabled";
    
    public static final String CIWi_REPO_RootDir = "ciwi.repoRootDir";
    public static final String CIWi_Exchange_RootDir = "ciwi.exchangeRootDir";
    
    
    
    /**
     DESCRIPTION:
     This function obtains the value of the "Deploy_RootDir" property. This
     property value is passed as an environment variable by a script that is
     controlling main program execution.

     @return rootPath - the deployment root path
     @throws UtilityException if the environment has not be set
     */
    public static String getDeployRoot() throws UtilityException {
        String deployRoot = System.getenv("MSE_DEPLOY_ROOT");
        if (deployRoot == null) {
            throw new UtilityException("*** FAILED to obtain MSE_DEPLOY_ROOT " +
                    "from environment\n" +
            "          Validate this Installation");
        }
        
        return deployRoot;
    }
}
